{php $mylink_data = m('shop')->getCategory();}
<link href="../addons/ewei_shop/plugin/article/template/imgsrc/article.css" rel="stylesheet">
<!-- mylink start -->
    <div id="modal-mylink" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog" style="width: 720px;">
            <div class="modal-content">
                <div class="modal-header" style="padding: 5px;">
                    <button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
                    <ul class="nav nav-pills" role="tablist">
                        
                        <li role="presentation" style="display: block;" id="categoryclick"><a aria-controls="link_cate" role="tab" data-toggle="tab" href="#link_cate" aria-expanded="false">商品分类</a></li>
                        
                    </ul>   
                </div>
                 <div class="modal-body tab-content">
                     

                     <div role="tabpanel" class="tab-pane link_cate" id="link_cate">
                         <div class="mylink-con">
                             {loop $mylink_data $goodcate}
                                
                                    <div class="mylink-line">
                                        {$goodcate['name']}
                                        <div class="mylink-sub">
                                            <a href="javascript:;" class="mylink-nav" data-name="{$goodcate['name']}" data-id="{$goodcate['id']}"选择</a>
                                        </div>
                                    </div>

                                    {loop $goodcate['children'] $goodcate2}
                                        
                                            <div class="mylink-line">
                                                <span style='height:10px; width: 10px; margin-left: 10px; margin-right: 10px; display:inline-block; border-bottom: 1px dashed #ddd; border-left: 1px dashed #ddd;'></span>
                                                {$goodcate2['name']}
                                                <div class="mylink-sub">
                                                    <a href="javascript:;" class="mylink-nav" data-name="{$goodcate2['name']}" data-id="{$goodcate2['id']}">选择</a>
                                                </div>
                                            </div>
                                            {loop $goodcate2['children'] $goodcate3}
                                               
                                                    <div class="mylink-line">
                                                        <span style='height:10px; width: 10px; margin-left: 30px; margin-right: 10px; display:inline-block; border-bottom: 1px dashed #ddd; border-left: 1px dashed #ddd;'></span>
                                                        {$goodcate3['name']}
                                                        <div class="mylink-sub">
                                                            <a href="javascript:;" class="mylink-nav" data-name="{$goodcate3['name']}" data-id="{$goodcate3['id']}">选择</a>
                                                        </div>
                                                    </div>
                                               
                                            {/loop}
                                        
                                    {/loop}
                                
                             {/loop}
                         </div>
                     </div>
                     
                 </div>
            </div>
        </div>
    </div>
</div>

<!-- mylink end -->
<script language="javascript">

    $(function() {
        $("#chkoption").click(function() {
            var obj = $(this);
            if (obj.get(0).checked) {
                $("#tboption").show();
                $(".trp").hide();
            }
            else {
                $("#tboption").hide();
                $(".trp").show();
            }
        });
    })
    
    $(document).on("click",".nav-link",function(){
        var id = $(this).data("id");
        if(id){
            $("#modal-mylink").attr({"data-id":id});
            $("#modal-mylink").modal();
        }
    });
    $(document).on("click",".mylink-nav",function(){
        var name = $(this).data("name");
        var cid = $(this).data("id");
        var id = $("#modal-mylink").attr("data-id");
        if(id){
            $("input[data-id="+id+"][data-name='categorynames']").val(name);
            $("input[data-id="+id+"][data-name='categoryids']").val(cid);
            $("#modal-mylink").attr("data-id","");
        }else{
            ue.execCommand('link', {name:name});
        }
        $("#modal-mylink .close").click();
    });
    $(".mylink-nav2").click(function(){
        var href = $("textarea[name=mylink_href").val();
        if(href){
            var id = $("#modal-mylink").attr("data-id");
            if(id){
                $("input[data-id="+id+"]").val(href);
                $("#modal-mylink").attr("data-id","");
            }else{
                ue.execCommand('link', {href:href});
            }
            $("#modal-mylink .close").click();
            $("textarea[name=mylink_href").val(""); 
        }else{
            $("textarea[name=mylink_href").focus();
            alert("链接不能为空!");
        }
    });
    
</script>